package com.example.recruitment.service.impl;

import com.example.recruitment.entity.Interview;
import com.example.recruitment.mapper.InterviewMapper;
import com.example.recruitment.service.InterviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class InterviewServiceImpl implements InterviewService {

    @Autowired
    private InterviewMapper interviewMapper;

    @Override
    public List<Interview> findAll(Interview query) {
        return interviewMapper.findAll(query);
    }

    @Override
    public Interview findById(Long id) {
        return interviewMapper.findById(id);
    }

    @Override
    public List<Interview> findByResumeId(Long resumeId) {
        return interviewMapper.findByResumeId(resumeId);
    }

    @Override
    @Transactional
    public boolean add(Interview interview) {
        return interviewMapper.insert(interview) > 0;
    }

    @Override
    @Transactional
    public boolean update(Interview interview) {
        return interviewMapper.update(interview) > 0;
    }

    @Override
    @Transactional
    public boolean deleteById(Long id) {
        return interviewMapper.deleteById(id) > 0;
    }

    @Override
    @Transactional
    public boolean updateStatus(Long id, String status) {
        return interviewMapper.updateStatus(id, status) > 0;
    }

    @Override
    @Transactional
    public boolean updateFeedback(Long id, String feedback) {
        return interviewMapper.updateFeedback(id, feedback) > 0;
    }

    @Override
    public long count() {
        return interviewMapper.count();
    }

    @Override
    public List<Interview> findLatest(int limit) {
        return interviewMapper.findLatest(limit);
    }

    @Override
    public long countTodayInterviews() {
        return interviewMapper.countTodayInterviews();
    }

    @Override
    public long countMonthlyHires() {
        return interviewMapper.countMonthlyHires();
    }
} 